<style>
.btn.btn-sm{line-height:1.6}
</style>
<div class="fui-page" ng-if="pagedata.op == 'list'">
	<div class="fui-tab fui-tab-danger" style="top:0">
			<a class="a external {{pagedata.params.status == 1?'active':''}}" ng-click="pagedata.params.status=1;tool.get_list('jy_mapfuwu/manage.store_order/list/',true);">待接单</a>
			<a class="a external {{pagedata.params.status == 2?'active':''}}" ng-click="pagedata.params.status=2;tool.get_list('jy_mapfuwu/manage.store_order/list/',true);">已接单</a>
			<a class="a external {{pagedata.params.status == 3?'active':''}}" ng-click="pagedata.params.status=3;tool.get_list('jy_mapfuwu/manage.store_order/list/',true);">已完成</a> 
	</div>
	<div class='fui-content order-list' style="top:0">
		<div class="fui-cellone" style="margin-top: 0;margin-bottom:0.2rem;background:#fff">
				<div class="fui-cellone-info">
					<div class="search-input" style="height:1.6rem">
						<form action="javascript:return true">
						<i id="searchsub" class="icon icon-sousuo1 bold" ng-click="tool.get_list('jy_mapfuwu/manage.store_order/list/',true);" style="line-height: 1.7rem;"></i>
						<input type="search" placeholder="搜索订单" class="search" ng-model="pagedata.params.keyword" style="height:1.6rem;text-align: left; color: #999; font-size:0.6rem;background:#f2f2f2;border-radius: 1rem;border: 1px solid #f2f2f2;" />
						</form>
					</div>
				 </div>
				 <div class="fui-cell-remark noremark gray" ng-click="tool.get_list('jy_mapfuwu/manage.store_order/list/',true);" style="padding-left:0.3rem">
					搜索
				</div>
		</div>
		<div class="weui_cells" style="margin:2%;padding:20rpx;" ng-repeat="item in pagedata.list">
			<div class="weui_noborder_sm">
                <div class="weui_cell_hd"><i class="icon icon-quanbudingdan" style="font-size:32rpx"/></div>
                <div class="weui_cell_bd weui_cell_primary"  style="padding:10rpx 20rpx">
                    <span>{{item.ordersn}}</span>
                </div>
                <div class="weui_cell_ft" style="color:#f60">{{pagedata.type[item.status]}}</div>
            </div>
			<div class="fui-list-group merchgroup" style="padding-top:0;margin-top:0">
				<div class="fui-list bold" style="color:#f60">服务网点</div>
				<div ng-if="item.store_id>0" class="fui-list">
					<a class="fui-list-media">
						<img class="round" ng-src="{{tomedia(pagedata.store.image) || '../core/resource/images/nopic.jpg'}}" />
					</a>
					<div class="fui-list-inner">
						<div class="title"><i class="icon icon-dianpu" style="color:#00c568"></i> {{pagedata.store.title || '网点名称'}}
						</div>
						<div class="title" style="font-size:26rpx">联系人：{{pagedata.store.name}}</div>
						<div class="title" style="font-size:26rpx">电话：{{pagedata.store.mobile}}</div> 
					</div>
					<a class="jump" href="tel:{{pagedata.store.mobile}}">
						<i class="icon icon-phone" style="width: 80rpx; text-align: center;"></i>
					</a>
				</div>
				<div ng-if="item.store_id>0" class="weui_noborder_sm">
					<div class="weui_cell_hd"><i class="icon icon-map" style="font-size:32rpx"/></div>
					<div class="weui_cell_bd weui_cell_primary"  style="padding:10rpx 20rpx">{{pagedata.store.pcd.city}} {{pagedata.store.pcd.district}} {{pagedata.store.pcd.street}}  {{pagedata.store.address}}<span ng-click="pagedata.openLocation(item.store);" class="red" style="font-size:26rpx;line-height: 1.5;"><i class="icon icon-lvyoutehui"></i>导航</span></div>
				</div>
			</div>
			<div class="fui-list-group">
			<div ng-repeat="g in item.goods" class="external">
                        <div class="fui-list goods-list">
                            <div class="fui-list-media">
                                <img class="" ng-src="{{tomedia(g.image) || '/core/resource/images/nopic.jpg'}}"/>
                            </div>
                            <div class="fui-list-inner">
                                <div class="text goodstitle towline">{{g.title}}</div>
                            </div>
                            <div class="fui-list-angle" style="width:120rpx">
                                ￥<span class="marketprice">{{g.price}}</span>
							</div>
						</div>
             </div>
			 </div>
			 <div class="weui_noborder_sm">
				<div class="weui_cell_hd"><i class="icon icon-kefuyouxian1" style="font-size:32rpx"/></div>
				<div class="weui_cell_bd weui_cell_primary syscolor" style="padding:10rpx 20rpx">{{item.type!=1?'立马维修':'预约维修'}}</div>
				<div ng-if="item.type!=1" class="weui_cell_ft bold" style="color:#f60">尽快处理</div>
				<div ng-if="item.type==1" class="weui_cell_ft bold" style="color:#f60">{{item.day}} {{item.time}}</div>
			</div>
			<div class="weui_noborder_sm">
					<div class="weui_cell_hd"><i class="icon icon-map" style="font-size:32rpx"/></div>
					<div class="weui_cell_bd weui_cell_primary"  style="padding:10rpx 20rpx">{{item.address}}<span ng-click="pagedata.openLocation('',item.address);"  class="red" style="font-size:26rpx;line-height: 1.5;"><i class="icon icon-lvyoutehui"></i>导航</span></div>
			</div>
			<div class="weui_noborder_sm">
				<div class="weui_cell_hd"><i class="icon icon-shijian" style="font-size:32rpx"/></div>
				<div class="weui_cell_bd weui_cell_primary"  style="padding:10rpx 20rpx">{{item.createtime}}</div>
				<div class="weui_cell_ft bold" style="color:#f60">￥{{item.price}}</div>
			</div>

			<div class="fui-list-group-title lineblock opblock r" style="height:auto;padding-bottom:0.3rem">
						<span class="status noremark">
							<div ng-if="item.status == 2" class="btn btn-sm btn-default-o order-delete" href="javascript:" ng-click="post({},'/manage.store_order/done/id='+item.id)">完成</div>
							<div ng-if="item.status == 0"  class="btn btn-sm btn-danger-o order-finish" href="javascript:" ng-click="post({},'/manage.store_order/dcel/id='+item.id)">确认取消</div>
							<div ng-if="item.status == 1"  class="btn btn-sm btn-danger-o order-finish" href="javascript:" ng-click="post({},'/manage.store_order/jie/id='+item.id)">确认接单</div>
						</span>
			</div>
		</div>
		<div class="content-empty" ng-if="pagedata.list.length == 0">
		  <i class="icon icon-cry" style="width: 240rpx;margin-bottom: 20rpx;"></i><div style="color: #999;font-size: 30rpx">您暂时没有订单！</div>
		</div>
	</div>
</div>
<div ng-include="sys_html('_footer')"></div>
<audio id="openvoice" controls preload="auto" style="display:none;">
	<source src="../core/resource/images/neworder.mp3"></source>
</audio>
<script type="text/javascript">
scope.pagedata.openLocation=function(item,address){
	var pcdaddress= item.pcd?item.pcd.province+item.pcd.city+item.pcd.district+item.pcd.street:'';
	var post={
		'address':address?address:pcdaddress+item.address,
		'city':item.pcd?item.pcd.city:''
	}
	scope.tool.get_latlng(post,function(res){
		var lat_lng = res.location
		var address_components = res.address_components
		wx.openLocation({
			latitude: lat_lng.lat, // 纬度，浮点数，范围为90 ~ -90
			longitude: lat_lng.lng, // 经度，浮点数，范围为180 ~ -180。
			name: pcdaddress, // 位置名
			address: item.address, // 地址详情说明
			scale: 20, // 地图缩放级别,整形值,范围从1~28。默认为最大
			infoUrl: '', // 在查看位置界面底部显示的超链接,可点击跳转
			success:function(){
				//alert(1111);
			},
			fail:function(res){
				scope.message('导航异常，可能是权限问题：'+res.errMsg);
			}
		});
	});
}
</script>
<script>
scope.tool.get_list('jy_mapfuwu/manage.store_order/list/',true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_mapfuwu/manage.store_order/list/');
}
scope.pagedata.openvoice=function(type){
	var voicetime = {};
    var openvoice;
	if(type || scope.pagedata.isopenvoice==1){
		 openvoice = setInterval(() => {
			if(scope.pagedata.isopenvoice!=1){
				clearInterval(openvoice);
				return false;
			}
			scope.get('jy_mapfuwu/index/getnew/',function(res){
						console.log('openvoice');console.log(res);
						if(res!='none'){
							if(!voicetime[res.id]){
								voicetime[res.id]=1;
								$("#openvoice")[0].play();
							}
							if(scope.pagedata.params.status==2){
								scope.tool.get_list('jy_mapfuwu/manage.store_order/list/',true);
							}
						}
			});
		}, 5000);
	}else{
		scope.get('jy_mapfuwu/index/setopenvoice/isopenvoice=0',function(res){});
	}
}
//scope.pagedata.openvoice();
</script>